package com.qf.mrboot1.controller;

import com.qf.mrboot1.entity.Pic;
import com.qf.mrboot1.result.ResponseData;
import com.qf.mrboot1.result.ResultCode;
import com.qf.mrboot1.service.PicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * (Pic)表控制层
 *
 * @author makejava
 * @since 2021-05-26 10:24:32
 */
@Api(value = "Pic")
@RestController //@Controller   @ResponseBody的组合
@RequestMapping("pics")
public class PicController {
    /**
     * 服务对象
     */
    @Autowired
    private PicService picService;

    @ApiOperation(value = "获取图片列表",notes = "根据URL中图片的类型获取相应图片列表")
    @ApiImplicitParam(name = "type",value = "图片类型lb-轮播，nav-导航",required = true,dataType = "string")
    @GetMapping("/{type}")
    public ResponseData queryPicByType(@PathVariable("type") String type){
        List<Pic> pics = picService.queryByType(type);
        return new ResponseData(ResultCode.SUCCESS,pics);
    }

    @ApiOperation(value = "获取所有图片",notes = "")
    @GetMapping("")
    public List<Pic> queryAll(Integer page,Integer limit){
        return new ArrayList<>();
    }

    @ApiOperation(value = "更新图片",notes = "根据id修改图片状态")
    @ApiImplicitParam(name = "pic",value = "图片详细实体pic",required = true,dataType = "Pic")
    @PatchMapping("")
    public String updatePic(@RequestBody Pic pic){
        return "success";
    }
    /**
     * 通过主键查询单条数据
     * http://localhost:8081/pic/selectOne/1
     * @param id 主键
     * @return 单条数据
     */
//    //http://localhost:8081/pic/1  查询
//    //http://localhost:8081/pic/1  删除
//    @ApiOperation(value = "selectOne",notes = "通过图片id获取到对应图片信息")
//    @ApiImplicitParam(name = "id",value = "图片的id",dataType = "int")//数据为整型
//    @GetMapping("id/{id}")
//    public Pic selectOne(@PathVariable Integer id) {
//        return this.picService.queryById(id);
//    }
//
////    @ApiOperation(value = "selectType",notes = "通过图片类型获取到对应图片列表信息")
////    @ApiImplicitParam(name = "type",value = "图片的类型")//
//    @ApiIgnore
//    @GetMapping("type/{type}")//作区分
//    public Pic selectByType(String type) {
//        Integer id = 1;
//        return this.picService.queryById(id);
//    }
//
//    @ApiOperation(value = "insert",notes = "添加预约信息")
//    @ApiImplicitParam(name = "pic",value = "图片对象")
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "uname",value = "用户名"),
////            @ApiImplicitParam(name = "tel",value = "电话号码")
////    })
//    @GetMapping("insert")
//    public Pic insert(/*String uname,String tel*/@RequestBody Pic pic) {
////        Integer id = 1;
////        return this.picService.queryById(id);
//        return  pic;
//    }


}
